﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hisun.Models;
using Hisun.Controllers;

using System.Data.Linq;
using System.Collections.Generic;

namespace Hisun.View.ReportQuery
{
    public partial class Report_FYFPB_DETAIL : AbcPageBase
    {
        HisunDBDataContext db = new HisunDBDataContext();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int MyCenterID = Convert.ToInt32(Request["CenterId"].ToString());
               

                string AccountPeriod = Request["MyAp"].ToString();

                string MyCostItem = Request["CostItem"].ToString();


                var IsValidString = from a in db.TABC_JS_AccountPeriods
                                    where a.会计期间ID == AccountPeriod
                                    select a;
                if (IsValidString.Count() == 0)
                {
                    Response.Write("<Script>alert('会计期间不存在，请检查输入是否正确')</Script>");
                    return;
                }
                else if (IsValidString.Count() == 1)
                {

                    string CurrentUser = Session[ServerVars.sysSessionUserName].ToString();
                    CostReport MyReport = new CostReport();
                    string myHtmlReport = "";
                    myHtmlReport = MyReport.WriteExcel_Report_FYFPB(MyCenterID, MyCostItem, AccountPeriod, CurrentUser);
                    Response.Redirect("/Report/UserReport/" + myHtmlReport + ".html");


                }
            
            }

        }
    }
}
